#pragma once

#include "Action.h"

namespace My {

template <typename S>
class TypedSegmentSet;

/** 
 *  Action that places a new segment 
 *  at the beginning of the set.
 */
template <typename S>
class CreateSegment: public Action
{
public:
	typedef S SegmentType;
public:
	CreateSegment(TypedSegmentSet<S> &, SegmentType *);
	~CreateSegment();
public:
	virtual String GetCaption() const;
	virtual bool Execute();
	virtual void Unexecute();
private:
	TypedSegmentSet<S> &	m_Segments;
	SegmentType *			m_pSegment;
};

/** 
 *  Action that deletes a segment
 */
template <typename S>
class DeleteSegment : public Action
{
public:
	typedef S SegmentType;
public:
	DeleteSegment(TypedSegmentSet<S> &, Size index);
	~DeleteSegment();
public:
	virtual String GetCaption() const;
	virtual bool Execute();
	virtual void Unexecute();
private:
	TypedSegmentSet<S> &	m_Segments;
	Size					m_Index;
	SegmentType *			m_pSegment;
	bool					m_Active;
};

/** 
 *  Action that places a segment at the given position
 */
template <typename S>
class MoveSegment : public Action
{
public:
	typedef S SegmentType;
public:
	MoveSegment(TypedSegmentSet<S> &, Size from, Size to);
	~MoveSegment();
public:
	virtual String GetCaption() const;
	virtual bool Execute();
	virtual void Unexecute();
private:
	TypedSegmentSet<S> &	m_Segments;
	Size					m_From;
	Size					m_To;
};

} // My

#include "Impl/SegmentActions.inl"